<template>
	<view class="superviseContent">
		<view class="upper">
			<view class="title">
				<image src="@/static/img/logo2.png" class="logo" />
				<!-- <view style="margin-right: 15px;" @tap="intelligentTask" ><text class="top-right-text">智能任务</text></view> -->
				<image src="/static/img/scan.png" class="scan" @tap="startScan" />
			</view>
		</view>
		<view class="centre">
			<view class="top">
				<view class="div" @tap="regulatoryListEntryActive(1, 3)">
					<view class="title">日常检查-待检查 <uni-badge v-show="dailyInspectionToBeCheckedNumberBadge"
							class="title-badge" type="error" text="1" size="normal" :is-dot="true"></uni-badge></view>
					<view class="number">
						<zero-loading v-if="dailyInspectionToBeCheckedNumber == '-'" type='annulus' position="static"
							:zIndex="0"></zero-loading>
						<text v-else>{{ dailyInspectionToBeCheckedNumber }}</text>户次
						<!-- <text>-</text>户次 -->
					</view>
				</view>
				<view class="div" @tap="regulatoryListEntryActive(2)">
					<view class="title">监管问题整改-待整改<uni-badge v-show="problemRectificationToBeRectifiedNumberBadge"
							class="title-badge" type="error" text="1" size="normal" :is-dot="true"></uni-badge></view>
					<view class="number">
						<zero-loading v-if="problemRectificationToBeRectifiedNumber == '-'" type='annulus'
							position="static" :zIndex="0"></zero-loading>
						<text v-else>{{ problemRectificationToBeRectifiedNumber }}</text>户次
						<!-- <text>-</text>户次 -->
					</view>
				</view>
				<view class="div" @tap="regulatoryListEntryActive(6)">
					<view class="title">双随机检查-待检查<uni-badge v-show="doubleRandomCheckToBeCheckedNumberBadge"
							class="title-badge" type="error" text="1" size="normal" :is-dot="true"></uni-badge></view>
					<view class="number">
						<zero-loading v-if="doubleRandomCheckToBeCheckedNumber == '-'" type='annulus' position="static"
							:zIndex="0"></zero-loading>
						<text v-else>{{ doubleRandomCheckToBeCheckedNumber }}</text>户次
						<!-- <text>-</text>户次 -->
					</view>
				</view>
				<view class="div" @tap="regulatoryListEntryActive(4, 0)">
					<view class="title">风险分级-待评分<uni-badge v-show="riskGradingToBeGradedNumberBadge" class="title-badge"
							type="error" text="1" size="normal" :is-dot="true"></uni-badge></view>
					<view class="number">
						<zero-loading v-if="riskGradingToBeGradedNumber == '-'" type='annulus' position="static"
							:zIndex="0"></zero-loading>
						<text v-else>{{ riskGradingToBeGradedNumber }}</text>户次
						<!-- <text>-</text>户次 -->
					</view>
				</view>
				<view class="div" @tap="regulatoryListEntryActive(1, 2)">
					<view class="title">超期未检查<uni-badge v-show="exceedTheTimeLimitBadge" class="title-badge"
							type="error" text="1" size="normal" :is-dot="true"></uni-badge></view>
					<view class="number">
						<zero-loading v-if="exceedTheTimeLimit == '-'" type='annulus' position="static"
							:zIndex="0"></zero-loading>
						<text v-else>{{ exceedTheTimeLimit }}</text>户次
						<!-- <text>-</text>户次 -->

					</view>
				</view>
				<view class="div" @tap="regulatoryListEntryActive(4, 1)">
					<view class="title">风险分级-待评级<uni-badge v-show="riskGradingToBeRatedNumberBadge" class="title-badge"
							type="error" text="1" size="normal" :is-dot="true"></uni-badge></view>
					<view class="number">
						<zero-loading v-if="riskGradingToBeRatedNumber == '-'" type='annulus' position="static"
							:zIndex="0"></zero-loading>
						<text v-else>{{ riskGradingToBeRatedNumber }}</text>户次
						<!-- <text>-</text>户次 -->
					</view>
				</view>
				<view class="div" @tap="regulatoryListEntryActive(5)">
					<view class="title">证后审查-待审查<uni-badge v-show="postCertificationReviewNumberBadge"
							class="title-badge" type="error" text="1" size="normal" :is-dot="true"></uni-badge></view>
					<view class="number">
						<zero-loading v-if="postCertificationReviewNumber == '-'" type='annulus' position="static"
							:zIndex="0"></zero-loading>
						<text v-else>{{ postCertificationReviewNumber }}</text>户次
						<!-- <text>-</text>户次 -->
					</view>
				</view>
				<!-- 		<view class="div" @tap="regulatoryListEntryActive(9)">
					<view class="title">调查处理-待检查</view>
					<view class="number">
						<text>{{ investigationAndProcessingPendingInspectionNumber }}</text>户次
					</view>
				</view> -->
				<!-- 		<view class="div" @tap="regulatoryListEntryActive(4,1)">
					<view class="title">风险分级-待审核</view>
					<view class="number">
						<text>{{ riskClassificationToBeReviewedNumber }}</text>户次
					</view>
				</view> -->
				<view class="div" @tap="regulatoryListEntryActive(8)">
					<view class="title">体系检查-待检查<uni-badge v-show="systemInspectionToBeInspectedNumberBadge"
							class="title-badge" type="error" text="1" size="normal" :is-dot="true"></uni-badge></view>
					<view class="number">
						<zero-loading v-if="systemInspectionToBeInspectedNumber == '-'" type='annulus' position="static"
							:zIndex="0"></zero-loading>
						<text v-else>{{ systemInspectionToBeInspectedNumber }}</text>户次
						<!-- <text>-</text>户次 -->
					</view>
				</view>
				<view class="div" @tap="regulatoryListEntryActive(11)">
					<view class="title">抽检不合格企业-查看<uni-badge v-show="spotCheckBadge" class="title-badge" type="error"
							text="1" size="normal" :is-dot="true"></uni-badge></view>
					<view class="number">
						<!-- <zero-loading v-if="spotCheck == '-'" type='annulus' position="static"
							:zIndex="0"></zero-loading> -->
						<!-- <text v-else>{{ spotCheck }}</text>户次 -->
						<text>-</text>户次
					</view>
				</view>
				<!-- 飞行检查是临时的应该没有待检查数量吧？ -->
				<view class="div" @tap="regulatoryListEntryActive(7)">
					<view class="title">飞行检查-待检查<uni-badge v-show="flightInspectionToBeInspectedNumberBadge"
							class="title-badge" type="error" text="1" size="normal" :is-dot="true"></uni-badge></view>
					<view class="number">
						<zero-loading v-if="flightInspectionToBeInspectedNumber == '-'" type='annulus' position="static"
							:zIndex="0"></zero-loading>
						<text v-else>{{ flightInspectionToBeInspectedNumber }}</text>户次
						<!-- <text>-</text>户次 -->
					</view>
				</view>
				<view class="div">
					<view class="title">包保问题整改-待整改</view>
					<view class="number">
						<!-- <zero-loading v-if="guaranteeTheRectification == '-'" type='annulus' position="static"
							:zIndex="0"></zero-loading> -->
						<!-- <text>{{guaranteeTheRectification}}</text>户次 -->
						<text>-</text>户次
					</view>
				</view>
				<view class="div" @tap="regulatoryListEntryActive(12)">
					<view class="title">待上传处罚决定书<uni-badge v-show="writtenDecisionOnPunishmentBadge" class="title-badge"
							type="error" text="1" size="normal" :is-dot="true"></uni-badge></view>
					<view class="number">
						<!-- <zero-loading v-if="writtenDecisionOnPunishment == '-'" type='annulus' position="static"
							:zIndex="0"></zero-loading> -->
						<!-- <text>{{writtenDecisionOnPunishment}}</text>户次 -->
						<text>-</text>户次
					</view>
				</view>
				<!-- 				<view class="div">
					<view class="title">风险分级-审核未通过</view>
					<view class="number">
						<text>{{ riskClassificationReviewFailedNumber }}</text>户次
					</view>
				</view> -->
			</view>
			<view class="bottom" id="bottom-box">
				<view class="div" :style="{ height: bottomHeight + 'px' }" v-for="(item, index) in regulatoryListEntry"
					:key="item.id" @click="regulatoryListEntryActive(item.id, 0)">
					<image :src="item.imageUrl" mode="aspectFill"
						:style="{ height: (bottomHeight - 44) + 'px', width: (bottomHeight - 44) + 'px' }"></image>
					<view class="title">{{ item.title }}</view>
				</view>
			</view>
		</view>
		<uni-popup ref="scan" type="bottom">
			<view class="scanContent">
				<view class="title">扫一扫</view>
				<view class="box">
					<view class="button">
						<button class="itemIdentification" @click="itemIdentification">物品识别</button>
						<button class="rawMaterialIdentification" @click="rawMaterialIdentification">原料识别</button>
					</view>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="rawMaterialIdentification" type="bottom" @change="handleChange">
			<view class="rawMaterialIdentificationContent" :style="{ height: popupHeight + 'px' }">
				<view class="title">原料识别</view>
				<view class="box">
					<uni-data-select :localdata="firstTypeList" :clear="true"
						@change="switchType($event, 1)"></uni-data-select>
					<uni-data-select style="margin-top: 20rpx;" :localdata="twoTypeList" :clear="true"
						@change="switchType($event, 2)"></uni-data-select>
					<uni-data-select style="margin-top: 20rpx;" :localdata="threeTypeList" :clear="true"
						@change="onnodeclick"></uni-data-select>
					<!-- <uni-data-picker 	placeholder="请选择原料" 	popup-title="请选择原料" 	:localdata="classDataTree" v-model="classValue"  @nodeclick="onnodeclick"></uni-data-picker> -->
					<scroll-view class="result" :style="{ height: (popupHeight - 220) + 'rpx', marginTop: '20rpx' }"
						:scroll-y="true" :show-scrollbar="false">
						<view v-if="rawMaterialFoodList.length != 0">
							<view class="recognize-title-view"><text class="recognize-title">识别结果</text></view>
							<uni-grid :column="1" :square="false">
								<uni-grid-item class="recognize-item" v-for="(value, index) in rawMaterialFoodList"
									:key="index">
									<view class="recognize-item-text-box">
										<input class="recognize-item-text-input" type="text"
											@input="inputChange($event, index)" :value="value" />
									</view>
								</uni-grid-item>
							</uni-grid>
						</view>
					</scroll-view>

					<view class="button">
						<button @click="addMatrialsAnalyze">添加原料</button>
						<button @click="matrialsAnalyze">原料分析</button>
					</view>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="identificationMethod" type="bottom">
			<view class="identificationMethodContent">
				<view class="title">识别方式</view>
				<view class="box">
					<view class="button">
						<button @click="selectPicture(scanType)">选择图片</button>
						<button @click="cameraPicture(scanType)">拍照</button>
					</view>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="selectPicture" type="bottom">
			<view class="selectPictureContent" :style="{ height: popupHeight + 'px' }">
				<view class="title">
					<view class="title-item"></view>
					<view class="title-item"><text class="title-text">识别结果</text></view>
					<view class="title-item" @tap="showCheckCompany" v-if="scanType == 5"
						style="justify-content: flex-end;padding-right: 15rpx;"><text
							class="title-right-text">推荐检查企业</text></view>
				</view>
				<scroll-view class="box" :style="{ height: (popupHeight - 80) + 'px', marginTop: '20rpx' }"
					:scroll-y="true" :show-scrollbar="false">
					<view class="result">
						<text v-if="scanType == 3" v-html="objectRecognition"></text>
						<view style="margin-top: 30rpx;" v-if="scanType == 5">
							<view class="recognize-title-view" style="background-color:  #794011;"><text
									class="recognize-title" style="color: #fff;">非法添加剂</text></view>
							<uni-grid :column="1" :square="false">
								<uni-grid-item class="recognize-item" v-for="(item, index) in illegalAdditivesList"
									:key="index">
									<view class="recognize-item-text-box">
										<text class="text" style="color:#e17821">{{ item.name }}</text>
									</view>
								</uni-grid-item>
							</uni-grid>
						</view>
						<view style="margin-top: 30rpx;" v-if="scanType == 5">
							<view class="recognize-title-view" style="background-color:  #137912;"><text
									class="recognize-title" style="color: #fff;">合法添加剂</text></view>
							<uni-grid :column="1" :square="false">
								<uni-grid-item class="recognize-item" v-for="(item, index) in qualifiedAdditivesList"
									:key="index">
									<view class="recognize-item-text-box">
										<text class="text" style="color:#247d0b">{{ item.name }}</text>
										<text class="text" style="color:#247d0b">最大用量:{{ item.useMax }}{{ item.unit
										}}</text>
									</view>
								</uni-grid-item>
							</uni-grid>
						</view>
						<view style="margin-top: 30rpx;" v-if="scanType == 5">
							<view class="recognize-title-view"><text class="recognize-title">不是添加剂</text></view>
							<uni-grid :column="1" :square="false">
								<uni-grid-item class="recognize-item" v-for="(item, index) in nonAdditiveList"
									:key="index">
									<view class="recognize-item-text-box">
										<text class="text" style="color:#424242">{{ item }}</text>
									</view>
								</uni-grid-item>
							</uni-grid>
						</view>
					</view>
					<view class="button">
						<button @click="back">返回</button>
					</view>
				</scroll-view>
			</view>
		</uni-popup>
		<uni-popup ref="dayCheckType" type="bottom">
			<view class="identificationMethodContent">
				<view class="title">检查路线规划方式</view>
				<view class="box">
					<view class="button">
						<button @click="intelligentPlanning()">按智能规划检查</button>
						<button @click="selfInspection()">自行安排检查</button>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
export default {
	components: {

	},
	data() {
		return {
			popupHeight: 0,
			scanType: 0,
			selectedTabId: 1,
			objectRecognition: '',
			rawMaterialStandardList: [], //标准用料
			rawMaterialFoodList: [], //食品用料
			qualifiedAdditivesList: [], //合法添加剂
			illegalAdditivesList: [], //非法添加剂
			nonAdditiveList: [], //不是添加剂
			firstTypeList: [],
			twoTypeList: [],
			threeTypeList: [],
			firstTypeId: '', //一级类型id
			twoTypeId: '', //二级类型id
			threeTypeId: '', //三级类型id
			classFoodType: '',
			dailyInspectionToBeCheckedNumber: '-',
			problemRectificationToBeRectifiedNumber: '-',
			doubleRandomCheckToBeCheckedNumber: '-',
			spotCheck: '-',
			exceedTheTimeLimit: '-',
			investigationAndProcessingPendingInspectionNumber: '-',
			flightInspectionToBeInspectedNumber: '-',
			riskGradingToBeGradedNumber: '-',
			systemInspectionToBeInspectedNumber: '-',
			riskGradingToBeRatedNumber: '-',
			riskClassificationToBeReviewedNumber: '-',
			riskClassificationReviewFailedNumber: '-',
			postCertificationReviewNumber: '-',
			guaranteeTheRectification: '-',
			writtenDecisionOnPunishment: '-',
			dailyInspectionToBeCheckedNumberBadge: false,
			doubleRandomCheckToBeCheckedNumberBadge: false,
			problemRectificationToBeRectifiedNumberBadge: false,
			investigationAndProcessingPendingInspectionNumberBadge: false,
			exceedTheTimeLimitBadge: false,
			systemInspectionToBeInspectedNumberBadge: false,
			postCertificationReviewNumberBadge: false,
			flightInspectionToBeInspectedNumberBadge: false,
			riskGradingToBeGradedNumberBadge: false,
			riskGradingToBeRatedNumberBadge: false,
			writtenDecisionOnPunishmentBadge: false,
			spotCheckBadge: false,
			bottomHeight: '0',
			dayCheckIndex: 0,
			isRun: true,
			statisticsTypeList: ['pingfen', 'pingji', 'richang', 'shuangsuiji', 'zhenggai', 'chaoqi', 'tixi', 'zhenghou', 'feixing', 'chufajuedingshu', 'choujian'
			],
			regulatoryListEntry: [{
				id: 1,
				imageUrl: '/static/img/regulatoryListEntry1.png',
				title: '日常检查'
			}, {
				id: 2,
				imageUrl: '/static/img/regulatoryListEntry2.png',
				title: '问题整改'
			}, {
				id: 3,
				imageUrl: '/static/img/regulatoryListEntry3.png',
				title: '主体信息'
			}, {
				id: 4,
				imageUrl: '/static/img/regulatoryListEntry4.png',
				title: '风险分级'
			}, {
				id: 5,
				imageUrl: '/static/img/regulatoryListEntry5.png',
				title: '证后审查'
			}, {
				id: 6,
				imageUrl: '/static/img/regulatoryListEntry6.png',
				title: '双随机检查'
			}, {
				id: 7,
				imageUrl: '/static/img/regulatoryListEntry7.png',
				title: '飞行检查'
			}, {
				id: 8,
				imageUrl: '/static/img/regulatoryListEntry8.png',
				title: '体系检查'
			}, {
				id: 9,
				imageUrl: '/static/img/regulatoryListEntry9.png',
				title: '调查处理'
			}, {
				id: 10,
				imageUrl: '/static/img/zhuanxiang.png',
				title: '专项检查'
			}, {
				id: 11,
				imageUrl: '/static/img/choujian.png',
				title: '抽检不合格'
			}
				/* 	,{
						id: 12,
						imageUrl: '/static/img/sampling.png',
						title: '查看企业'
					},{
						id: 13,
						imageUrl: '/static/img/statistics.png',
						title: '统计查询'
					}, */

			]
		}
	},
	async onReady() {
		//页面大小改变重新计算
		const that = this;
		this.popupHeight = uni.getSystemInfoSync().screenHeight * 0.7
		//获取距离顶部高度,动态计算底部菜单按钮高度
		let h = this.regulatoryListEntry.length % 3 == 0 ? this.regulatoryListEntry.length / 3 : this
			.regulatoryListEntry.length / 3 + 1
		const query = uni.createSelectorQuery().in(that);
		query.select('#bottom-box').boundingClientRect(data => {
			that.bottomHeight = (uni.getSystemInfoSync().windowHeight - data.top) / h;
		}).exec();
		//this.isRun = true
		for (var i = 0; i < that.statisticsTypeList.length; i++) {
			//if(that.isRun){ 
			switch (that.statisticsTypeList[i]) {
				case 'richang':
					this.dailyInspectionToBeCheckedNumber = '-'
					break;
				case 'shuangsuiji':
					this.doubleRandomCheckToBeCheckedNumber = '-'
					break;
				case 'zhenggai':
					this.problemRectificationToBeRectifiedNumber = '-'
					break;
				case 'chaoqi':
					this.exceedTheTimeLimit = '-'
					break;
				case 'tixi':
					this.systemInspectionToBeInspectedNumber = '-'
					break;
				case 'zhenghou':
					this.postCertificationReviewNumber = '-';
					break;
				case 'feixing':
					this.flightInspectionToBeInspectedNumber = '-'
					break;
				case 'pingfen':
					this.riskGradingToBeGradedNumber = '-'
					break;
				case 'pingji':
					this.riskGradingToBeRatedNumber = '-'
					break;
				case 'chufajuedingshu':
					this.writtenDecisionOnPunishment = '-'
					break;
				case 'choujian':
					this.spotCheck = '-'
					break;
			}
			that.initData(that.statisticsTypeList[i]);
			await new Promise(resolve => setTimeout(resolve, 500)); // 暂停 1 秒
			//}
		}

	},
	onHide() {
		//this.isRun = false
	},
	async onShow() {
		//只有在页面的时候才会查询，页面隐藏的时候就停止查询


	},
	methods: {
		async initData(ytype) {
			let res = await uni.$api.getTaskCountStatistics({ type: ytype });
			switch (ytype) {
				case 'richang':
					this.dailyInspectionToBeCheckedNumber = res.data.data.SHU
					const dailyInspectionToBeCheckedNumberStorage = uni.getStorageSync(
						"dailyInspectionToBeCheckedNumber") || "0";
					this.dailyInspectionToBeCheckedNumberBadge = parseInt(this
						.dailyInspectionToBeCheckedNumber) > parseInt(
							dailyInspectionToBeCheckedNumberStorage) ? true : false;
					uni.setStorageSync("dailyInspectionToBeCheckedNumber", this
						.dailyInspectionToBeCheckedNumber);
					break;
				case 'shuangsuiji':
					this.doubleRandomCheckToBeCheckedNumber = res.data.data.SHU
					const doubleRandomCheckToBeCheckedNumberStorage = uni.getStorageSync(
						"doubleRandomCheckToBeCheckedNumber") || "0";
					this.doubleRandomCheckToBeCheckedNumberBadge = parseInt(this
						.doubleRandomCheckToBeCheckedNumber) > parseInt(
							doubleRandomCheckToBeCheckedNumberStorage) ? true : false;
					uni.setStorageSync("doubleRandomCheckToBeCheckedNumber", this
						.doubleRandomCheckToBeCheckedNumber);
					break;
				case 'zhenggai':
					this.problemRectificationToBeRectifiedNumber = res.data.data.SHU
					const problemRectificationToBeRectifiedNumberStorage = uni.getStorageSync(
						"problemRectificationToBeRectifiedNumber") || "0";
					this.problemRectificationToBeRectifiedNumberBadge = parseInt(this
						.problemRectificationToBeRectifiedNumber) > parseInt(
							problemRectificationToBeRectifiedNumberStorage) ? true : false;
					uni.setStorageSync("problemRectificationToBeRectifiedNumber", this
						.problemRectificationToBeRectifiedNumber);
					break;
				// case 'diaocha':
				// 	this.investigationAndProcessingPendingInspectionNumber = res.data.data[i].SHU
				// 	const investigationAndProcessingPendingInspectionNumberStorage = uni.getStorageSync("investigationAndProcessingPendingInspectionNumber") || "0";
				// 	this.investigationAndProcessingPendingInspectionNumberBadge =  parseInt(this.investigationAndProcessingPendingInspectionNumber) > parseInt(investigationAndProcessingPendingInspectionNumberStorage) ? true : false;
				// 	break;
				case 'chaoqi':
					this.exceedTheTimeLimit = res.data.data.SHU
					const exceedTheTimeLimitStorage = uni.getStorageSync("exceedTheTimeLimit") || "0";
					this.exceedTheTimeLimitBadge = parseInt(this.exceedTheTimeLimit) > parseInt(
						exceedTheTimeLimitStorage) ? true : false;
					uni.setStorageSync("exceedTheTimeLimit", this.exceedTheTimeLimit);
					break;
				case 'tixi':
					this.systemInspectionToBeInspectedNumber = res.data.data.SHU
					const systemInspectionToBeInspectedNumberStorage = uni.getStorageSync(
						"systemInspectionToBeInspectedNumber") || "0";
					this.systemInspectionToBeInspectedNumberBadge = parseInt(this
						.systemInspectionToBeInspectedNumber) > parseInt(
							systemInspectionToBeInspectedNumberStorage) ? true : false;
					uni.setStorageSync("systemInspectionToBeInspectedNumber", this
						.systemInspectionToBeInspectedNumber);
					break;
				case 'zhenghou':
					this.postCertificationReviewNumber = res.data.data.SHU
					const postCertificationReviewNumberStorage = uni.getStorageSync(
						"postCertificationReviewNumber") || "0";
					this.postCertificationReviewNumberBadge = parseInt(this.postCertificationReviewNumber) >
						parseInt(postCertificationReviewNumberStorage) ? true : false;
					uni.setStorageSync("postCertificationReviewNumber", this.postCertificationReviewNumber);
					break;
				case 'feixing':
					this.flightInspectionToBeInspectedNumber = res.data.data.SHU
					const flightInspectionToBeInspectedNumberStorage = uni.getStorageSync(
						"flightInspectionToBeInspectedNumber") || "0";
					this.flightInspectionToBeInspectedNumberBadge = parseInt(this
						.flightInspectionToBeInspectedNumber) > parseInt(
							flightInspectionToBeInspectedNumberStorage) ? true : false;
					uni.setStorageSync("flightInspectionToBeInspectedNumber", this
						.flightInspectionToBeInspectedNumber);
					break;
				case 'pingfen':
					this.riskGradingToBeGradedNumber = res.data.data.SHU
					const riskGradingToBeGradedNumberStorage = uni.getStorageSync(
						"riskGradingToBeGradedNumber") || "0";
					this.riskGradingToBeGradedNumberBadge = parseInt(this.riskGradingToBeGradedNumber) >
						parseInt(riskGradingToBeGradedNumberStorage) ? true : false;
					uni.setStorageSync("riskGradingToBeGradedNumber", this.riskGradingToBeGradedNumber);
					break;
				case 'pingji':
					this.riskGradingToBeRatedNumber = res.data.data.SHU
					const riskGradingToBeRatedNumberStorage = uni.getStorageSync(
						"riskGradingToBeRatedNumber") || "0";
					this.riskGradingToBeRatedNumberBadge = parseInt(this.riskGradingToBeRatedNumber) >
						parseInt(riskGradingToBeRatedNumberStorage) ? true : false;
					uni.setStorageSync("riskGradingToBeRatedNumber", this.riskGradingToBeRatedNumber);
					break;
				// case 'shenhe':
				// 	this.riskClassificationToBeReviewedNumber = res.data.data[i].SHU
				// 	break;
				case 'chufajuedingshu':
					this.writtenDecisionOnPunishment = res.data.data.SHU
					const writtenDecisionOnPunishmentStorage = uni.getStorageSync(
						"writtenDecisionOnPunishment") || "0";
					this.writtenDecisionOnPunishmentBadge = parseInt(this.writtenDecisionOnPunishment) >
						parseInt(writtenDecisionOnPunishmentStorage) ? true : false;
					uni.setStorageSync("writtenDecisionOnPunishment", this.writtenDecisionOnPunishment);
					break;
				case 'choujian':
					this.spotCheck = res.data.data.SHU
					const spotCheckStorage = uni.getStorageSync("spotCheck") || "0";
					this.spotCheckBadge = parseInt(this.spotCheck) > parseInt(spotCheckStorage) ? true : false;
					uni.setStorageSync("spotCheck", this.spotCheck);
					break;
			}

		},
		intelligentTask() {
			//进入智能任务 
			uni.navigateTo({
				url: '/pages/supervise/intelligenceTask'
			});
		},
		regulatoryListActive(id) {
			if (id == 1) {
				uni.navigateTo({
					url: '/pages/inspect/inspect'
				});
			} else if (id === 2) {
				uni.navigateTo({
					url: '/pages/rectification/rectification'
				});
			} else if (id == 3) {
				uni.navigateTo({
					url: '/pages/inspect/doubleRandom/inspect'
				});
			} else if (id === 4) {
				uni.navigateTo({
					url: '/pages/investigation/investigation'
				});
			}
		},
		regulatoryListEntryActive(id, index) {
			if (id == 1) {
				this.dayCheckIndex = index;
				this.$refs.dayCheckType.open("buttom");
			} else if (id === 2) {
				uni.navigateTo({
					url: '/pages/rectification/rectification?status=2'
				});
			} else if (id === 3) {
				uni.navigateTo({
					url: '/pages/subjectInformation/subjectInformation'
				});
			} else if (id === 4) {
				uni.navigateTo({
					url: '/pages/risk/riskList?tabIndex=' + index + '&inspectStatus=2'
				});

			} else if (id === 5) {
				uni.navigateTo({
					url: '/pages/postCertificationReview/postCertificationReview'
				});
			} else if (id == 6) {
				uni.navigateTo({
					url: '/pages/inspect/doubleRandom/inspect'
				});
			} else if (id == 7) {
				uni.navigateTo({
					url: '/pages/flightPlan/planList'
				});
			} else if (id == 8) {
				uni.navigateTo({
					url: '/pages/schemePlan/planList'
				});
			} else if (id === 9) {
				uni.navigateTo({
					url: '/pages/investigation/investigation'
				});
			} else if (id === 10) {
				uni.navigateTo({
					url: '/pages/specialInspect/specialInspect'
				});
			} else if (id === 11) {
				uni.navigateTo({
					url: '/pages/spotCheck/spotCheck'
				});
			} else if (id === 12) {
				uni.navigateTo({
					url: '/pages/sampling/samplingCompany'
				})
			} else if (id == 13) {
				console.log('id', id)
				uni.navigateTo({
					url: '/pages/statisticsQuery/statisticsQuery'
				});
			}
		},
		intelligentPlanning() {
			//智能规划检查
			uni.navigateTo({
				url: '/pages/inspect/intelligentInspect?index=' + this.dayCheckIndex,
				success: (res) => {

					this.$refs.dayCheckType.close();
				}
			});
		},
		selfInspection() {
			//自行检查
			uni.navigateTo({
				url: '/pages/inspect/inspect?index=' + this.dayCheckIndex,
				success: (res) => {

					this.$refs.dayCheckType.close();
				}
			});
		},
		async startScan() {
			this.$refs.scan.open('bottom');
			await uni.$api.getTaskCountStatistics();
			uni.$api.getMaterialsTypeListByParent();


		},
		// 物品识别
		itemIdentification() {
			this.$refs.identificationMethod.open('bottom')
			this.scanType = 3
		},
		// 选择图片
		selectPicture(number) {
			uni.chooseImage({
				count: 1,
				success: (res) => {
					const tempFilePaths = res.tempFilePaths
					this.uploadImage(tempFilePaths[0], number)
					this.$refs.identificationMethod.close('bottom')
					this.$refs.scan.close('bottom')
					uni.showLoading({
						title: '加载中...',
						mask: true
					});
				}
			})
		},
		// 拍照
		cameraPicture(number) {
			uni.chooseImage({
				sourceType: ['camera'],
				success: (res) => {
					this.uploadImage(res.tempFilePaths[0], number)
					this.$refs.identificationMethod.close('bottom')
					this.$refs.scan.close('bottom')
					uni.showLoading({
						title: '加载中...',
						mask: true
					});
				}
			});
		},
		//识别
		uploadImage(filePath, number) {
			const that = this;
			if (number === 5) {
				var formData = {
					type: number,
					foodType: this.classFoodType
				}
			} else {
				var formData = {
					type: number
				}
			}
			uni.uploadFile({
				url: 'scan/getResult',
				filePath: filePath,
				name: 'file',
				formData: formData,
				header: {
					'content-Type': 'multipart/form-data',
				},

				success: (res) => {
					if (number === 5) {
						//this.objectRecognition = ''
						const obj = JSON.parse(res.data);
						console.log(obj)
						that.rawMaterialFoodList = obj.data.text
						//获取一级原料类别
						uni.$api.getMaterialsTypeListByParent().then(res => {
							if (res.data.code != '0') {
								return
							}
							that.firstTypeList = res.data.data;
							//显示识别结果
							that.$refs.rawMaterialIdentification.open('bottom');
						},
							err => {
								//显示识别结果
								that.$refs.rawMaterialIdentification.open('bottom');
							});




						//this.rawMaterialStandardList = obj.data.baList
						// if(obj.data.text) {
						// 	obj.data.text.forEach(item => {
						// 		this.objectRecognition += item.text + "<br>";
						// 	});
						// }else {
						// 	uni.showToast({
						// 		title:'上传失败',
						// 		icon:'error'
						// 	})
						// }
					} else {
						//物品识别
						that.objectRecognition = ''
						const obj = JSON.parse(res.data);
						that.objectRecognition = obj.data.text.replace(/\n/g, '<br>')
						//打开识别结果窗口
						that.$refs.selectPicture.open('bottom')
					}
					//关闭选择图片还是拍照
					that.$refs.identificationMethod.close('bottom')
					uni.hideLoading();
				},
				fail: () => {
					uni.hideLoading();
					uni.showToast({
						title: '图片选择错误',
						icon: 'error'
					})
				}
			})
		},
		addMatrialsAnalyze() {
			this.rawMaterialFoodList.push("")
		},
		async matrialsAnalyze() {
			// 原料识别后的分析
			//判断原料类型是否选择
			if (this.classFoodType == '') {
				//如果没有选择原料类型，则提示选择
				uni.showModal({
					title: '提示',
					content: '请选择原料类型',
					showCancel: false
				})
				return;
			}
			//开始通过后台对比
			uni.showLoading({
				title: '开始识别...',
				mask: true
			})
			const res = await uni.$api.getMaterialsScanResult({
				classFoodType: this.classFoodType,
				rawMaterialFoodList: this.rawMaterialFoodList.join(",")
			});
			uni.hideLoading();
			if (res.data.code != '0') {
				uni.showToast({
					title: '识别失败'
				});
				return;
			}
			console.log(res)
			this.qualifiedAdditivesList = res.data.data.qualifiedAdditivesList //合法添加剂
			this.illegalAdditivesList = res.data.data.illegalAdditivesList //非法添加剂
			this.nonAdditiveList = res.data.data.nonAdditiveList //不是添加剂

			//打开识别结果窗口
			this.$refs.selectPicture.open('bottom')
		},
		// 物品识别返回
		back() {
			this.$refs.selectPicture.close('bottom')
		},
		// 原料识别
		async rawMaterialIdentification() {
			//扫描原料  打开摄像头 
			this.scanType = 5
			this.$refs.identificationMethod.open('bottom')
			// uni.navigateTo({
			// 	url: '/pages/supervise/scan'
			// })

		},
		inputChange(e, index) {
			// 原料类别输入框输入内容监控/
			this.rawMaterialFoodList[index] = e.target.value;
		},
		async switchType(e, index) {
			//获取二级原料类别
			try {
				this.onnodeclick(e, index);
				const res = await uni.$api.getMaterialsTypeListByParent({
					parentId: e
				});
				if (index == 1) {
					this.twoTypeList = res.data.data
				} else {
					this.threeTypeList = res.data.data
				}
				this.popupShow = true;
				this.$refs.rawMaterialIdentification.open('bottom')
			} catch (error) {
				console.error(error)
			}
		},
		onnodeclick(e, index) {
			if (index == 1) {
				this.firstTypeId = e
				for (var i = 0; i < this.firstTypeList.length; i++) {
					if (this.firstTypeList[i].id == e) {
						this.classFoodType = this.firstTypeList[i].code
					}
				}
			} else if (index == 2) {
				this.twoTypeId = e
				for (var i = 0; i < this.twoTypeList.length; i++) {
					if (this.twoTypeList[i].id == e) {
						this.classFoodType = this.twoTypeList[i].code
					}
				}
			} else {
				this.threeTypeId = e
				for (var i = 0; i < this.threeTypeList.length; i++) {
					if (this.threeTypeList[i].id == e) {
						this.classFoodType = this.threeTypeList[i].code
					}
				}
			}


		},
		showCheckCompany() {
			// 查看原料识别后推荐企业列表
			uni.navigateTo({
				url: '/pages/supervise/companyList?typeCode=' + this.classFoodType
			})

		},
		handleChange({
			show
		}) {
			if (show) {
				this.popupShow = true;
			} else {
				this.popupShow = false;
			}
		}
	},
	watch: {

	},
}
</script>

<style lang="scss">
page {
	background: #F9F9F9;
}

.superviseContent {
	background-color: #F9F9F9;

	.upper {
		position: fixed;
		z-index: 1;
		top: 0;
		left: 0;
		width: 100%;

		.title {
			background: url('../../static/img/inspectBg.png');
			background-size: cover;
			width: 100%;
			height: 125rpx;
			line-height: 125rpx;
			position: relative;
			display: flex;
			justify-content: space-between;
			align-items: flex-end;

			.logo {
				width: 320rpx;
				height: 60rpx;
				margin: 0 0 20rpx 32rpx;
			}

			.top-right-text {
				font-size: 25rpx;
				color: #FFFFFF;
			}

			.scan {
				width: 38rpx;
				height: 38rpx;
				margin: 0 20rpx 30rpx 0rpx;
			}
		}


	}

	.centre {
		margin: 124rpx auto 0;

		.top {
			display: flex;
			flex-wrap: wrap;

			.div {
				display: flex;
				align-items: center;
				justify-content: space-between;
				width: 50%;
				height: 80rpx;
				border-top: 2rpx solid #D6D6D6;
				position: relative;

				.title {
					font-size: 21rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
					margin: 0 0 0 20rpx;
					display: flex;
					flex-direction: row;
					align-items: flex-start;
					justify-content: flex-start;

					.title-badge {}
				}

				.number {
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					font-size: 14rpx;
					color: #333333;
					display: flex;
					align-items: flex-end;
					margin: 0 20rpx 0 18rpx;

					text {
						margin: 0 6rpx 0 0;
						font-size: 26rpx;
						text-align: end;
						color: #0552A9;
					}
				}

				&:nth-child(4n-3),
				&:nth-child(4n-2) {
					background: #FFFFFF;
				}

				&:nth-child(4n-1),
				&:nth-child(4n) {
					background: #F9F9F9;
				}

				&::before {
					display: block;
					content: "";
					width: 2rpx;
					height: 100%;
					background: #D6D6D6;
					position: absolute;
					right: 0;
				}

			}
		}

		.bottom {
			display: flex;
			justify-content: flex-start;
			flex-wrap: wrap;
			border-top: 2rpx solid #B6B6B6;

			.div {
				flex: 33.33%;
				max-width: 33.33%;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				position: relative;
				border-bottom: 2rpx solid #B6B6B6;

				.title {
					font-size: 21rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
				}

				&::before {
					display: block;
					content: "";
					width: 2rpx;
					height: 100%;
					background: #D6D6D6;
					position: absolute;
					right: 0;
				}
			}
		}
	}

	/deep/.uni-popup {
		z-index: 9999;
	}
}


.scanContent,
.itemIdentificationContent,
.identificationMethodContent,
.rawMaterialIdentificationContent {
	background: #FFFFFF;
	border-radius: 20rpx 20rpx 0 0;

	.title {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		background: url('../../static/img/popupTitle.png') no-repeat center center;
		background-size: cover;
		font-size: 25rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		// text-indent: 45rpx;
		text-align: center;
	}

	.box {

		.button {
			margin: 58rpx auto 0;
			padding: 0 95rpx 24rpx 95rpx;
			display: flex;

			button {
				width: 269rpx;
				height: 55rpx;
				line-height: 55rpx;
				background: #0552A9;
				border-radius: 10rpx;
				font-size: 20rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #fff;

				// 		&.itemIdentification {
				// 			color: #fff;
				// 		}

				// 		&.rawMaterialIdentification {
				// 			background: none;
				// 			border: 1rpx solid #979797;
				// 			color: #979797;
				// 		}
			}
		}
	}
}

.selectPictureContent {
	background: #FFFFFF;
	border-radius: 20rpx 20rpx 0 0;

	.title {
		width: 750rpx;
		background: url('../../static/img/popupTitle.png') no-repeat center center;
		background-size: cover;
		height: 80rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-items: center;

		.title-item {
			width: 650rpx;
			display: flex;
			flex-direction: row;
			justify-content: center;
			align-items: center;

			.title-text {
				line-height: 80rpx;
				font-size: 25rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				text-align: center;
			}

			.title-right-text {
				line-height: 80rpx;
				font-size: 20rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				color: #FFFFFF;
				text-align: right;
				margin-left: 10rpx;
			}
		}
	}


	.box {

		.result {
			// height: 50vh;
			overflow-x: hidden;
			padding: 20rpx 40rpx 0 40rpx;

			.recognize-title-view {
				width: 675rpx;
				height: 50rpx;
				background-color: #e8e8e8;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-top: 20rpx;
				border-radius: 14px 14px 0px 0px;

				.recognize-title {
					color: #100f0f;
					font-size: 25rpx;
					text-align: center;
				}

			}

			.table {
				overflow-x: hidden;
				display: flex;
				flex-wrap: wrap;

				.rawMaterialIdentificationData {
					display: flex;
					flex-direction: row;
					width: 50%;


					view {
						border-right: 2rpx solid #979797;
						border-bottom: 2rpx solid #979797;
						font-size: 20rpx;
						margin-bottom: 30rpx;
						color: rgb(191, 81, 0);
						padding: 0 15rpx;
						width: calc(100% - 34rpx);
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}
			}
		}

		.button {
			margin: 18rpx auto 0;
			padding: 0 0 24rpx 0;

			button {
				width: 90%;
			}
		}
	}
}

.rawMaterialIdentificationContent {

	/deep/.uni-data-tree-dialog {
		position: relative;
	}

	.box {
		padding: 20rpx;

		.uni-data-tree {
			width: 90%;
			margin: 20rpx auto;
			padding: 10rpx 0;

			.uni-data-tree-input {

				.input-value.input-value-border {

					.selected-area {
						font-size: 24rpx;
					}
				}
			}
		}

		.button {
			margin: 18rpx auto 0;
			padding: 0 0 24rpx 0;

			button {
				width: 40%;
			}
		}
	}
}

.recognize-title-view {
	width: 720rpx;
	height: 50rpx;
	background-color: #e8e8e8;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-top: 20rpx;
	border-radius: 14px 14px 0px 0px;

	.recognize-title {
		color: #100f0f;
		font-size: 25rpx;
		text-align: center;
	}

}

.recognize-item {
	height: 70rpx;

	.recognize-item-text-box {
		padding: 10rpx 10rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;

		.recognize-item-text-input {
			width: 700rpx;
			border: 0px solid #dddddd;
			text-align: right;
			border-radius: 10rpx;
			height: 50rpx;
			line-height: 50rpx;
			color: #414141;
		}
	}

	.text {
		color: #6c6c6c;
		font-size: 25rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
}
</style>